package com.yangchao.webflux.exception;

import org.slf4j.Logger;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


//全局异常处理
@RestControllerAdvice
public class GlobalExceptionHandler {

    Logger log = org.slf4j.LoggerFactory.getLogger(GlobalExceptionHandler.class);

    @ExceptionHandler(ArithmeticException.class)
    public String error(ArithmeticException exception){
        System.out.println("发生了数学运算异常"+exception);
        return "ArithmeticException，哈哈...";
    }

    @ExceptionHandler(Exception.class)
    public String error(Exception exception){
        log.info("GlobalExceptionHandler");
        throw new RuntimeException("发生了异常");
    }
}
